﻿using System.Linq;
using System.Windows;
using BlogApp.Data.Service;
using BlogApp.WP8.ViewModel;
using Microsoft.Phone.Controls;

namespace BlogApp.WP8.View
{
    public partial class LoadingPage : PhoneApplicationPage
    {
        private MainViewModel _vm;

        // Constructor
        public LoadingPage()
        {
            InitializeComponent();

            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();


            _vm = (MainViewModel) DataContext;
            Loaded += OnLoaded;
        }

        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            //_vm.LoadCategoriesCommand.Execute(null);
            //_vm.LoadRecentPosts.Execute(null);

            _vm.LoadDataCommand.Execute(null);
        }

        // Sample code for building a localized ApplicationBar
        //private void BuildLocalizedApplicationBar()
        //{
        //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
        //    ApplicationBar = new ApplicationBar();

        //    // Create a new button and set the text value to the localized string from AppResources.
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);

        //    // Create a new menu item with the localized string from AppResources.
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}
    }
}